<?php
include_once 'gift_cert/lib/Mail.php';
include_once 'gift_cert/lib/ImageText.php';
include_once 'gift_cert/lib/Common.php';

define("SYS_PATH",dirname(__FILE__)."/");

//$to      = 'orders@digitalpickle.com';
//$to      = 'doanvuthuan@gmail.com';
//$subject = 'Test message';
//$message = 'This is test message at ' . date("m/d/y h:i:s");
//$headers = 'From: info@digitalpickle.com';

//$rs = mail($to, $subject, $message, $headers);
//echo $rs;

$req = 'cmd=_notify-synch';
$req .= '&tx='.$_GET['tx'];
$req .= '&at='.'37Wy104Cw4QkZOvF26hh1CmPpV18NGjIzJNwEmf4LAHgq63uR6r9oGbtJ1S';

//foreach ($_GET as $key => $value) {
//$value = urlencode(stripslashes($value));
//$req .= "&$key=$value";
//}

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {
	echo "error";
} else {
	fputs ($fp, $header . $req);
	while (!feof($fp)) {
		$res = fgets ($fp, 1024);
		if (strcmp ($res, "VERIFIED") == 0) {
			echo "VERIFIED";
		}
		else if (strcmp ($res, "INVALID") == 0) {
			echo "INVALID";
		}
		else
		{
			echo $res . "<br>";
		}
	}
	fclose ($fp);
}


echo "<PRE>POST:";
print_r($_POST);
echo "</PRE>";
echo "<PRE>GET:";
print_r($_GET);
echo "</PRE>";

//phpinfo();

exit;


?>